<template>
	<div class="bottom">
		<!-- <div class="lo" v-for="(item,index) in $store.state.list" :key="index"> -->
		<div class="lo" v-for="(item,index) in list" :key="index">
			<img :src="item.pic" alt="">
			<div class="love_bt">
				<div class="love_bt_le">
					<h4>{{item.goodsname}}</h4>
					<p>￥{{item.price}}/份</p>
				</div>
				<div class="love_bt_ri" @click="cancelCollect(index)">
					<img src="../static/footer2.png" alt="">
					<p>取消收藏</p>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	import {mapState,mapActions} from 'vuex';
	export default {
		name:"LoveItem",
		props:{
			index:0
		},
		data() {
			return {
				
			};
		},
		computed:{
			...mapState(['list'])
		},
		methods:{
			...mapActions(['delItem']),
			cancelCollect(n){
				// console.log("1.子组件发射自定义事件",n)
				// this.$emit('del-love',n) ,不再想父组件发射事件，直接通过vuex来处理
				//派发一个action，处理数据
				console.log("派发一个action，处理数据")
				// this.$store.dispatch("delItem",n)
				this.delItem(n)
			}
		}
	}
</script>

<style lang="less">
	.bottom{
		padding: 0 30rpx ;
		
		.lo{
			display: flex;
			flex-direction: column;
			align-items: center;
			border-radius: 15rpx;
			box-shadow: 2rpx 2rpx 10rpx #ccc;
			margin-bottom: 30rpx;
			
			img{
				width: 100%;
				height: 420rpx;
				border-radius: 15rpx 15rpx 0 0;
			}
			
			.love_bt{
				width: 92%;
				display: flex;
				justify-content: space-between;
				padding: 20rpx;
				
				.love_bt_le{
					display: flex;
					flex-direction: column;
					justify-content: center;
					
					p{
						color: red;
						font-weight: 600;
					}
				}
				
				.love_bt_ri{
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;
					
					img{
						width: 50rpx;
						height: 50rpx;
					}
					
					p{
						color: #ccc;
						margin-top: 10rpx;
					}
				}
			}
		}
	}
</style>